<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>v-on调用传参</title>
    <style>
        .box {
            width: 200px;
            padding: 20px;
            border: 2px solid #222;
            border-radius: 10px;
        }
    </style>
</head>

<body>
    <!--
        @click="buy(实参)"
        methods:{
            buy(形参){
            
            }
        }
    -->
    <div id="app">
        <div class="box">
            <h3>小黑盒自动售货机</h3>
            <button @click="buy(5)">可乐5元</button>
            <button @click="buy(10)">咖啡10元</button>
            <button @click="buy(8)">煎饼8元</button>
        </div>
        <h3>银行卡余额：{{money}}元</h3>
    </div>

    <script src="./script/vue.js"></script>
    <script>
        const app = new Vue({
            el: '#app',
            data: {
                money: 100
            },
            methods: {
                buy(pic) {
                    this.money -= pic
                }
            },
        })
    </script>
</body>

</html>